package com.dxq.test.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dxq.test.R;
import com.dxq.test.db.Group;
import com.dxq.test.db.Vaccine;

import java.util.List;

/**
 * Author: zsh
 * Date: 2023/11/17
 * Describe: 疫苗列表adapter
 */
public class VaccineAdapter extends BaseQuickAdapter<Vaccine, BaseViewHolder> {

    public VaccineAdapter(int layoutResId) {
        this(layoutResId, null);
    }

    public VaccineAdapter(int layoutResId, @Nullable List<Vaccine> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, Vaccine item) {
        //holder.setText(R.id.tvSize, String.valueOf(1 + holder.getLayoutPosition()));
        holder.setText(R.id.tvCode, item.getCode());
        holder.setText(R.id.tvType, item.getType());
        holder.setText(R.id.tvName, item.getName());
        if (item.getGroup() != null) {
            holder.setText(R.id.tvTitle, "分群名称：");
            holder.setText(R.id.tvLabelName, item.getGroup().getName());
        }
        if (item.getLabel() != null) {
            holder.setText(R.id.tvTitle, "个体编码：");
            holder.setText(R.id.tvLabelName, item.getLabel().getName());
        }
        holder.setText(R.id.tvTime, item.getTime());
    }
}
